import re
import xml.etree.ElementTree as ET


def loadXMLFile_old(file_name):
    file = open(file_name)
    lines = file.readlines()
    outer = []
    inner = []
    for line in lines:
        if line.find('<points>') >= 0:
            tks  = re.split(r'\(|,|\)', line)
            # print(tks)
            outer.append([int(tks[1]), int(tks[2])])
            inner.append([int(tks[4]), int(tks[5])])

    return outer, inner

def loadXMLFile(file_name):

    outer = []
    inner = []
    # Passing the path of the
    # xml document to enable the
    # parsing process
    tree = ET.parse(file_name)

    # getting the parent tag of
    # the xml document
    root = tree.getroot()

    for shape in root:
        # print(shape)

        if shape.find('name').text == "arrow":
            line = shape.find('points').text
            # print(line)
            tks  = re.split(r'\(|,|\)', line)
            # print(tks)
            outer.append([int(float(tks[1])), int(float(tks[2]))])
            inner.append([int(float(tks[4])), int(float(tks[5]))])

    return outer, inner



if __name__ == "__main__":
    res = loadXMLFile('E:\iynaur-s-vector-drawing\draw\clip.xml')
    print(res)

    # res = buildBiasFromXML('E:\iynaur-s-vector-drawing\draw\clip.xml')
    print(res)
